#!/bin/bash -f

# Copyright (c) Stanford University, The Regents of the University of
#               California, and others.
#
# All Rights Reserved.
#
# See Copyright-SimVascular.txt for additional details.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject
# to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# simvascular specific additions

export SV_OS=REPLACEME_SV_OS
export SOFTWARE_PLATFORM=REPLACEME_SOFTWARE_PLATFORM
export CXX_COMPILER_VERSION=REPLACEME_CXX_COMPILER_VERSION
export FORTRAN_COMPILER_VERSION=REPLACEME_FORTRAN_COMPILER_VERSION
export LIB_BUILD_DIR=REPLACEME_LIB_BUILD_DIR
export SV_VERSION=REPLACEME_SV_VERSION

# must specify paths in unix style
export OPEN_SOFTWARE_BINARIES_TOPLEVEL=REPLACEME_OPEN_SOFTWARE_BINARIES_TOPLEVEL
export SV_HOME=REPLACEME_SV_HOME

#export SV_STATIC_BUILD=REPLACEME_SV_STATIC_BUILD

export SV_USE_PYTHON=REPLACEME_SV_USE_PYTHON

################################################################
# YOU PROBABLY DON'T NEED TO CHANGE ANYTHING BELOW THIS LINE.  #
################################################################

# SimVascular addition
export LD_LIBRARY_PATH=$SV_HOME/BuildWithMake/Lib/$LIB_BUILD_DIR:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$SV_HOME/BuildWithMake/Bin/plugins:$LD_LIBRARY_PATH

# Tcl/Tk additions
export TCL_LIBRARY=REPLACEME_TCL_LIBRARY
export TK_LIBRARY=REPLACEME_TK_LIBRARY
export LD_LIBRARY_PATH=REPLACEME_TCLTK_SO_PATH:$LD_LIBRARY_PATH

# Python additions
export PYTHONHOME=REPLACEME_PYTHON_HOME
export PYTHONPATH="REPLACEME_PYTHON_PACKAGES"
export LD_LIBRARY_PATH=REPLACEME_SV_PYTHON_SO_PATH:$LD_LIBRARY_PATH

case "$SV_OS" in
"windows" )
    export SV_SITE_PACKAGES=`cygpath --windows -t mixed $SV_HOME/Python/site-packages`
    export PYTHONPATH="$SV_SITE_PACKAGES;$PYTHONPATH"
  ;;
* )
  export PYTHONPATH=$SV_HOME/Python/site-packages:$PYTHONPATH
 ;;
esac

# GDCM additions
export LD_LIBRARY_PATH=REPLACEME_SV_GDCM_SO_PATH:$LD_LIBRARY_PATH

# Freetype additions
export LD_LIBRARY_PATH=REPLACEME_SV_FREETYPE_SO_PATH:$LD_LIBRARY_PATH

# hdf5 additions
export LD_LIBRARY_PATH=REPLACEME_SV_HDF5_SO_PATH:$LD_LIBRARY_PATH

# ITK additions
export LD_LIBRARY_PATH=REPLACEME_ITK_SO_PATH:$LD_LIBRARY_PATH

# Tkcximage addition
export TKCXIMAGE_DLL=REPLACEME_TKCXIMAGE_DLL

# qt additions
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:REPLACEME_QT_SO_PATH
export QT_PLUGIN_PATH=REPLACEME_QT_PLUGIN_PATH
export QT_QPA_FONTDIR=REPLACEME_QT_QPA_FONTDIR
export QTWEBENGINEPROCESS_PATH=$SV_HOME/BuildWithMake/Bin/QtWebEngine/REPLACEME_QT_WEBENGINE_PROC
# vtk additions
case "$SV_OS" in
"windows" )
export LD_LIBRARY_PATH=REPLACEME_VTK_SO_PATH:$LD_LIBRARY_PATH
# leave VTK_RENDERER blank for win32
;;
"linux" )
export LD_LIBRARY_PATH=REPLACEME_VTK_SO_PATH:$LD_LIBRARY_PATH
export VTK_RENDERER=OpenGL
;;
"macosx" )
export LD_LIBRARY_PATH=REPLACEME_VTK_SO_PATH:$LD_LIBRARY_PATH
;;
* )
export LD_LIBRARY_PATH=REPLACEME_VTK_SO_PATH:$LD_LIBRARY_PATH
;;
esac
# Vtk Tcl path additions
export TCLLIBPATH=REPLACEME_VTK_TCL_LIB_PATH
# Vtk Python additions (included above with python site-packages)

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:REPLACEME_INTEL_COMPILER_SO_PATH

# Opencascade additions
export LD_LIBRARY_PATH=REPLACEME_SV_OPENCASCADE_SO_PATH:$LD_LIBRARY_PATH

# MITK additions
if [ -z "$SV_PLUGIN_PATH" ]
then
    SV_PLUGIN_PATH_ORIGINAL=""
else
    SV_PLUGIN_PATH_ORIGINAL=$SV_PLUGIN_PATH
fi
export LD_LIBRARY_PATH=REPLACEME_SV_MITK_SO_PATH:$LD_LIBRARY_PATH
export SV_PLUGIN_PATH="REPLACEME_SV_MITK_PLUGIN_PATH"

case "$SV_OS" in
"windows" )
    export SV_PLUGIN_PATH_PLUGINS=`cygpath --windows -t mixed $SV_HOME/BuildWithMake/Bin/plugins`
    export SV_PLUGIN_PATH="$SV_PLUGIN_PATH;$SV_PLUGIN_PATH_PLUGINS;$SV_PLUGIN_PATH_ORIGINAL"
  ;;
* )
  export SV_PLUGIN_PATH=$SV_PLUGIN_PATH:$SV_HOME/BuildWithMake/Bin/plugins:$SV_PLUGIN_PATH_ORIGINAL
 ;;
esac

# needed for macosx
export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
export DYLD_PRINT_LIBRARIES=1

# need to convert to dos style paths on windows
case "$SV_OS" in
 "windows" )
export OPEN_SOFTWARE_BINARIES_TOPLEVEL=`cygpath --windows -t mixed $OPEN_SOFTWARE_BINARIES_TOPLEVEL`
export SV_HOME=`cygpath --windows -t mixed $SV_HOME`
export PYTHONHOME=`cygpath --windows -t mixed $PYTHONHOME`
export TCL_LIBRARY=`cygpath --windows -t mixed $TCL_LIBRARY`
export TK_LIBRARY=`cygpath --windows -t mixed $TK_LIBRARY`
export TKCXIMAGE_DLL=`cygpath --windows -t mixed $TKCXIMAGE_DLL`
#export SV_PLUGIN_PATH=`cygpath --windows -t mixed $SV_PLUGIN_PATH`
export QTWEBENGINEPROCESS_PATH=`cygpath --windows -t mixed $QTWEBENGINEPROCESS_PATH`
export PATH=$LD_LIBRARY_PATH:$PATH
;;
esac
